module.exports = (grunt) ->
	grunt.initConfig
		rootDir: "./"
		contentDir: "<%= rootDir%>/public"
		outputDir: "<%= rootDir%>/dist"
		
		coffee:
			compile:
				options:
					bare: true
				files: [
					expand: true
					cwd: "<%= srcDir%>"
					src: ["<%= rootDir%>/private/**/*.coffee", "<%= rootDir%>/app.coffee"]
					dest: "<%= outputDir%>"
					ext: ".js"
				]
					
		stylus:
			compile:
				files:[
					"<%= outputDir%>/public/css/main.css" : ["<%= contentDir%>/css/*.styl"]
				]
				
		cssmin:
			minify:
				expand: true
				cwd: "<%= outputDir%>/public/css"
				src: "*.css"
				dest: "<%= outputDir%>/public/css/"
				ext: ".min.css"
				
		copy:
			views:
				files: [{
						expand: true
						cwd: "<%= rootDir%>/private/views"
						src: "**"
						dest: "<%= outputDir%>/private/views"
					}
				]
					
			images:
				files: [
					expand: true
					cwd: "<%= rootDir%>/public/img"
					src: "**"
					dest: "<%= outputDir%>/public/img"
				]
					
			fonts:
				files: [
					expand: true
					cwd: "<%= rootDir%>/public/font"
					src: "**"
					dest: "<%= outputDir%>/public/font"
				]
					
			scripts:
				files: [
					expand: true
					cwd: "<%= rootDir%>/public/js"
					src: "**"
					dest: "<%= outputDir%>/public/js" 
				]
			
			components:
				files: [
					expand: true
					cwd: "<%= rootDir%>/public/components"
					src: "**"
					dest: "<%= outputDir%>/public/components"
				]
		
		clean:
			build: ["<%= outputDir%>"]
			
		exec:
			server:
				cmd: "node <%= outputDir%>/app"
	
	grunt.registerTask "build", ["clean:build",
								 "copy:views",
								 "copy:images",
								 "copy:fonts",
								 "copy:scripts",
								 "copy:components",
								 "coffee:compile", 
								 "stylus:compile",
								 "cssmin:minify"]
	
	grunt.registerTask "run", ["build", "exec:server"]
	
	grunt.loadNpmTasks "grunt-contrib-coffee"
	grunt.loadNpmTasks "grunt-contrib-cssmin"
	grunt.loadNpmTasks "grunt-contrib-stylus"
	grunt.loadNpmTasks "grunt-contrib-copy"
	grunt.loadNpmTasks "grunt-contrib-clean"
	grunt.loadNpmTasks "grunt-exec"